<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Constexpr domain source - Boost.Outcome documentation</title>
<link rel="stylesheet" href="../../css/boost.css" type="text/css">
<meta name="generator" content="Hugo 0.52 with Boostdoc theme">
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>

<link rel="icon" href="../../images/favicon.ico" type="image/ico"/>
<body><div class="spirit-nav">
<a accesskey="p" href="../../experimental/worked-example/message.html"><img src="../../images/prev.png" alt="Prev"></a>
    <a accesskey="u" href="../../experimental/worked-example.html"><img src="../../images/up.png" alt="Up"></a>
    <a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="../../experimental/worked-example/implicit_conversion.html"><img src="../../images/next.png" alt="Next"></a></div><div id="content">
  <div class="titlepage"><div><div><h1 style="clear: both">Constexpr domain source</h1></div></div></div>
  <p>Back in <a href="../../experimental/worked-example/constructor.html">The constructor</a>, we
declared but did not implement a <code>.get()</code> function which returns a constexpr static
instance of the domain. We implement this now:</p>

<div class="code-snippet"><div class="highlight"><pre class="chroma"><code class="language-c++" data-lang="c++"><span class="c1">// 100% constexpr instantiation
</span><span class="c1"></span><span class="k">constexpr</span> <span class="n">_file_io_error_domain</span> <span class="n">file_io_error_domain</span><span class="p">;</span>
<span class="kr">inline</span> <span class="k">constexpr</span> <span class="k">const</span> <span class="n">_file_io_error_domain</span> <span class="o">&amp;</span><span class="n">_file_io_error_domain</span><span class="o">::</span><span class="n">get</span><span class="p">()</span>
<span class="p">{</span>
  <span class="k">return</span> <span class="n">file_io_error_domain</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div><a href="https://github.com/boostorg/outcome/tree/master/doc/src/snippets/experimental_status_code.cpp#L143" class="code-snippet-url" target="_blank">View this code on Github</a></div>


<p>As this is 100% constexpr, it can be (and is under optimisation) implemented entirely
in the mind of the compiler with no run time representation.</p>


        </div><p><small>Last revised: January 26, 2019 at 23:38:56 UTC</small></p>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../../experimental/worked-example/message.html"><img src="../../images/prev.png" alt="Prev"></a>
    <a accesskey="u" href="../../experimental/worked-example.html"><img src="../../images/up.png" alt="Up"></a>
    <a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="../../experimental/worked-example/implicit_conversion.html"><img src="../../images/next.png" alt="Next"></a></div></body>
</html>
